home *** CD-ROM | disk | FTP | other *** search
- /*
- * Fibonacci benchmark
- */
-
- #include <stdio.h>
- #include "timer.h"
- #define NTIMES 10
- #define NUMBER 24
-
- main()
- {
- int i;
- unsigned value, fib();
- init_timer();
- start_timer();
- printf("%d iterations:", NTIMES);
- for(i = 1; i <= NTIMES; i++)
- value = fib(NUMBER);
-
- printf("fibonacci(%d)=%u.\n",NUMBER,value);
- print_elapsed("Fibbonacci benchmark", USERMIN);
- exit(0);
- }
-
- unsigned fib(x)
- int x;
- {
- if(x>2)
- return(fib(x-1) +fib(x-2));
- else
- return(1);
- }
-